#ifndef _UI_ELEMENT_H
#define _UI_ELEMENT_H

///////////////////////////////////////////////////////////////////////////
//																		 //
//	Author:		Michael Mozdzierz										 //
//	Date:		11/02/2014												 //
//	Purpose:	Define the base class for all user interface objects like//
//				buttons and check boxes									 //
//																		 //
///////////////////////////////////////////////////////////////////////////

#include "..\..\..\..\EdgeMath\Vectors.h"
#include "..\..\..\..\EdgeGameCore\BaseGameComponent.h"
#include "..\..\..\..\EdgeGameCore\Delegate.h"
#include "..\..\..\..\EdgeControls\Input.h"
#include "..\..\..\..\EdgeMath\Geometry.h"
#include <d3d11.h>

class Texture2D;

// Serves as a base class for other ui elements like buttons or track bars
class UiElement : public BaseGameComponent
{
protected:
	// the screen space occupied by this element
	Box2D clientRect;

	// the texture for the ui element
	Texture2D* texture = nullptr;

	UiElement(void) = default;
public:
	virtual ~UiElement(void);

	// update the ui element
	virtual void Update(float dt) override;
	// draw the ui element
	virtual void Draw(void) override;

	// get the current position of this ui element
	Vector2 getPosition(void) const { return clientRect.getPosition(); }

	// get the texture for this ui element
	Texture2D* getTexture(void) const { return texture; }

	// set the position of this ui element
	void setPosition(Vector2& value) { clientRect.setPosition(value); }

	// set the texture of this ui element
	void setTexture(Texture2D* value) { texture = value; }

	// event raised when the user hovers the mouse cursor over this element
	Delegate<mouse_event_handler> OnMouseHover;
	// event raised when the mouse hovers over this element, and the left mouse
	// button is pressed
	Delegate<mouse_event_handler> OnClicked;

	// get the screen space occupied by this element
	Box2D getClientRect(void) const { return clientRect; }
};

#endif